package demo.Thread;

/**
 * @Auther: hjy(lc))
 * @Date: 2022/8/9-08-09-14:38
 * @Description：demo.Thread     线程优先级
 */
public class Thread_grade {
    public static void main(String[] args) {
        Thread thread1 = new Thread(){
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getName() + "--------------");
            }
        };
        thread1.start();
        Thread thread2 = new Thread(){
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getName() + "--------------");
            }
        };
        thread2.setPriority(8);    //更改thread2的的优先级
        thread2.start();
        System.out.println("thread-0 : " + thread1.getPriority());   //打印线程1的优先级    5
        System.out.println("thread-1 : " + thread2.getPriority());   //打印线程2的优先级    8
        System.out.println("main : " + Thread.currentThread().getPriority());     //     5
    }
}
